package com.lzhsite.technology.designPattern.chainms;

/**
 * 责任链模式：如果有多个对象都有机会处理请求，责任链可使请求的发送者和接收者解耦，
 * 请求沿着责任链传递，直到有一个对象处理了它为止
 * 
 * 场景：财务审批  
 * 1.小组领导接到的审批 小于5000小组领导审批,否则执行2
 * 2.部门领导接到的审批 大于5000 且小于10000部门领导审批,否则执行3
 * 3.副主席接到的审批     大于10000且小于50000副主席审批,否则执行4
 * 4.主席接到的审批         大于50000主席审批,否则执行1
 * 
 * @author lzhcode
 */
public class MainTest {

	public static void main(String[] args) {
		
		Client mClient = new Client();
		Approver GroupLeader = new GroupApprover("Tom");
		Approver VicePresident = new VicePresidentApprover("Kate");
		Approver DepartmentLeader = new DepartmentApprover("Jerry");
		Approver President = new PresidentApprover("Bush");
		
		GroupLeader.SetSuccessor(DepartmentLeader);
		DepartmentLeader.SetSuccessor(VicePresident);
		VicePresident.SetSuccessor(President);
		President.SetSuccessor(GroupLeader);
		
		VicePresident.ProcessRequest(mClient.sendRequst(1, 100, 40));
		VicePresident.ProcessRequest(mClient.sendRequst(2, 200, 40));
		VicePresident.ProcessRequest(mClient.sendRequst(3, 300, 40));
		VicePresident.ProcessRequest(mClient.sendRequst(4, 400, 140));
		
	}


}
